package assist.domain.model;

import java.io.Serializable;

import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;


@PersistenceCapable(detachable = "true")
public class Player implements Serializable, Comparable<Player>
{
    @NotPersistent
    private static final long serialVersionUID = 1L;    
    @PrimaryKey
    @Persistent
    private Long playerId;
    
    @Persistent
    private String name;    
    public Player()
    {
    }
    public String getName()
    {
        return this.name;
    }
    public void setName(String name)
    {
        this.name = name;
    }
    /**
     * @param playerId the playerId to set
     */
    public void setPlayerId(Long playerId)
    {
        this.playerId = playerId;
    }
    /**
     * @return the playerId
     */
    public Long getPlayerId()
    {
        return playerId;
    }

    @Override
    public int compareTo(Player player)
    {
       return this.name.compareTo(player.name);
    }
    
    @Override
    public boolean equals(Object player)
    {
        if (player instanceof Player)
            return this.playerId.equals(((Player)player).getPlayerId());
        return super.equals(player);
    } 
    
    public int hashCode()
    {
        return this.playerId.hashCode();
    }
}
